﻿@model CleverCMS.Cms.Services.ViewModels.AdminEditPageViewModel
<script type="text/javascript" src="@Url.Content("~/areas/clevercms.admin/scripts/custom/page_edit.js")"></script>

<div class="widget green">
    <div class="widget-title">
        <h4><i class="icon-reorder"></i>Page</h4>
    </div>
    <div class="widget-body">

        <div id="failureResult" class="alert alert-block alert-error" style="display: none">
            <h4 class="alert-heading">Error!</h4>
            <p id="errortext">
                <div class="validation-summary-valid" data-valmsg-summary="true">
                    <span>Edit was unsuccessful. Please correct the errors and try again.</span>
                    <ul>
                        <li style="display: none"></li>
                    </ul>
                </div>
            </p>
        </div>

        <div class="alert alert-block alert-success" 
             style="display: none" 
             id="successResult">
            <h4 class="alert-heading">Success!</h4>
            <p>
                Items was successfully saved.
            </p>
        </div>

        <form   action="/admin/page/edit/" 
                class ="search_form general_form" 
                data-ajax="true" 
                data-ajax-failure="failureSave" 
                data-ajax-method="POST" 
                data-ajax-success="successSave" 
                id ="editEntryForm" 
                method="post">
            
            <input  data-val="true" 
                    data-val-number="The field Id must be a number." 
                    data-val-required="The Id field is required." 
                    id="Page_Id" 
                    name="Page.Id" 
                    type="hidden" 
                    value="" />

            <input  data-val="true" 
                    data-val-date="The field CreatedAt must be a date." 
                    data-val-required="The CreatedAt field is required." 
                    id="Page_CreatedAt" 
                    name="Page.CreatedAt" 
                    type="hidden" 
                    value="@{DateTime.Now.ToString();}" />
            
            <input  id="Page_Alias" 
                    name="Page.Alias" 
                    type="hidden" 
                    value="" />
            
            <input  data-val="true" 
                    data-val-date="The field ModifiedAt must be a date." 
                    data-val-required="The ModifiedAt field is required." 
                    id="Page_ModifiedAt" 
                    name="Page.ModifiedAt" 
                    type="hidden" 
                    value="@{DateTime.Now.ToString();}" />
            
            <input  data-val="true" 
                    data-val-number="The field StatusId must be a number." 
                    data-val-required="The StatusId field is required." 
                    id="Page_StatusId" 
                    name="Page.StatusId" 
                    type="hidden" 
                    value="1" />
            
            <input  data-val="true" 
                    data-val-number="The field AuthorId must be a number." 
                    id="Page_AuthorId" 
                    name="Page.AuthorId" 
                    type="hidden" 
                    value="" />
            
            <div>
                <div>
                    <div style="width:73%; float:left" >
                        <label>Post Title</label>
                        <input  class="text-box" 
                                data-val="true" 
                                data-val-required="Enter post title" 
                                id="Page_PageTitle" 
                                name="Page.PageTitle" 
                                style="width: 100%;" 
                                type="text" 
                                value="" />
                    </div>
                    <div style="float:left" >
                        <label>Category</label>
                        @Html.DropDownList("Page.CategoryId", Model.Categories)
                    </div>
                </div>
                <span class="clearfix"></span>
                <div class="row" 
                     id="permalink" 
                     style="display: none">
                    <label>Permalink</label>
                    <div class="inputs wideInputs">
                        <table>
                            <tr>
                                <td style="vertical-align:top;">
                                    <span style="float:left; width:70px;padding-left:5px">
                                        <span>
                                            <a  class="open button" 
                                                id="permalinkUrl" 
                                                href='/pages/page-with-rating/' 
                                                target="_blank"><span>OPEN</span>
                                            </a>
                                        </span>
                                    </span>
                                    
                                </td>
                                <td>
                                    <span style="float:left;width:100%; padding-left:10px">
                                    <span  id="pageUrl"></span>
                                    <span id="pagePermalink"></span>
                                    </span>
                                    
                                    <div id="pageAlias" style="float:left;display: none">
                                        <table>
                                            <tr>
                                                <td style="width: 420px">
                                                    <input type="text" class="text wide" id="txtNewPageAlias" value="" />
                                                </td>
                                                <td>
                                                    <span class="button send_form_btn">
                                                        <span>
                                                            <a href="#" class="button" onclick="updateAlias(); return false;">
                                                                <span class="alt_btn">SAVE</span>
                                                            </a>
                                                        </span>
                                                    </span>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </td>
                                <td>
                                    <span id="changeAliasButtonContainer" class="button send_form_btn" style="padding-left:10px;float:left;" >
                                        <span>
                                            <a href="#" class="button" onclick="changeAlias(); return false;">
                                                <span class="alt_btn">EDIT</span>
                                            </a>
                                        </span>
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <span class="clearfix"></span>
                <div>
                    <div>
                        <label>Content</label>
                        <textarea cols="20" id="pageContent" name="Page.PageContent" >
                    </textarea>
                        <script type="text/javascript">
                            CKEDITOR.replace('pageContent',
                                {
                                    height: '600px',
                                    scayt_autoStartup: false,
                                    filebrowserBrowseUrl: "/Scripts/ckfinder/ckfinder.html",
                                    filebrowserImageBrowseUrl: "/Scripts/ckfinder/ckfinder.html?type=Images",
                                    filebrowserFlashBrowseUrl: "/Scripts/ckfinder/ckfinder.html?type=Flash",
                                    filebrowserUploadUrl: "/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&amp;type=Files",
                                    filebrowserImageUploadUrl: "/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&amp;type=Images",
                                    filebrowserFlashUploadUrl: "/Scripts/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&amp;type=Flash",
                                    filebrowserWindowWidth: "1000",
                                    filebrowserWindowHeight: "1200"
                                });
                        </script>
                    </div>
                </div>
                <span class="clearfix"></span>
                <div>
                    <div style="float: left; width: 47%;">
                        <label>Tags</label>
                        <input class="text" id="tags" name="Tags" style="width: 100%; padding: 4px 1%;" type="text" value="" />
                    </div>
                    <div class="spacer"></div>
                    <div style="float: left; width: 47%;">
                        <label>Meta Title</label>
                        <textarea class="text" cols="20" id="Page_SeoTitle" name="Page.SeoTitle" rows="2" style="width: 100%; padding: 5px 1%; height: 100px;"></textarea>
                    </div>
                </div>
                <span class="clearfix"></span>
                <div>
                    <div style="float: left; width: 47%;">
                        <label>Meta Keywords</label>
                        <textarea class="text" cols="20" id="Page_MetaKeywords" name="Page.MetaKeywords" rows="2" style="width: 100%; padding: 4px 1%; height: 80px;"></textarea>
                    </div>
                    <div class="spacer"></div>
                    <div style="float: left; width: 47%;">
                        <label>Meta Description</label>
                        <textarea class="text" cols="20" id="Page_MetaDescription" name="Page.MetaDescription" rows="2" style="width: 100%; padding: 4px 1%; height: 80px;"></textarea>
                    </div>
                </div>

                <span class="clearfix"></span>
                
                <div>
                    <div>
                        <div style="float: right; width: 250px; margin-right: 0;">
                            <button type="submit" class="btn btn-success" name="save_page"><i class="icon-ok icon-white"></i>Publish</button>
                            <button class="btn btn-inverse" onclick="cleanUpForm(); return false;"><i class="icon-refresh icon-white"></i>Reset</button>
                            <button class="btn btn-inverse" onclick="history.back()"><i class="icon-ban-circle icon-white"></i>Back</button>
                        </div>
                    </div>

                    <div style="float: right; margin-right: 20px;">
                         @Html.DropDownList("PageStatusId", Model.PageStatuses)
                    </div>
                    
                    <label style="float: right; margin-right: 5px; line-height: 2em;">Status:</label>
                    
                    <div style="float: right; margin-right: 20px;">
                        <input  data-val="false" 
                                data-val-required="The ShowRating field is required." 
                                id="Page_ShowRating" 
                                name="Page.ShowRating" 
                                type="checkbox" 
                                value="false" />
                        <input name="Page.ShowRating" type="hidden" value="false" />
                    </div>
                    
                    <label style="float: right; margin-right: 5px; line-height: 2em;">Show rating:</label>
                    
                    <div style="float: right; margin-right: 20px;">
                        <input  data-val="false" 
                                data-val-required="The HasComments field is required." 
                                id="Page_HasComments" 
                                name="Page.HasComments" 
                                type="checkbox" 
                                value="false" />
                        <input name="Page.HasComments" type="hidden" value="false" />
                    </div>
                    
                    <label style="float: right; margin-right: 5px; line-height: 2em;">Show comments:</label>
                </div>

                <span class="clearfix"></span>
            </div>
        </form>
    </div>
</div>

